class TeamHalveSummaryController < ApplicationController
  def index
  	
  end

  def new
  	@game = Game.find(params[:game_id])
    @home_team = @game.home_team
    @visiting_team = @game.visiting_team

    @team_halve_summary = [TeamHalveSummary.new(:halve => 1, :team => @home_team, :game => @game),
                          TeamHalveSummary.new(:halve => 2, :team => @home_team, :game => @game),
                          TeamHalveSummary.new(:halve => 1, :team => @visiting_team, :game => @game),
                          TeamHalveSummary.new(:halve => 2, :team => @visiting_team, :game => @game) ]
  end

  def add

    @summaries = params[:team_halve_summary].values.collect do |entry|
      @summary = TeamHalveSummary.new(entry)
      
      unless @summary.save then
        flash[:notice] = "Missing fields %s" % @summary.errors.collect {|e| e }.join('<br />')
        return redirect_to :action => :new, :game_id => @summary.game.id 
      end
      
      
      @summary
    end

    


  end

  def show
  end

  def edit
  end

end
